package daily.oct;

public class lc2221 {
    public int triangularSum(int[] nums) {
        int len = nums.length;
        while (len > 1) {
            int[] newNums = new int[len - 1];
            for (int i = 0; i < len - 1; i++) {
                newNums[i] = (nums[i] + nums[i + 1]) % 10;
            }
            len--;
            nums = newNums;
        }
        return nums[0];
    }

    public static void main(String[] args) {
        lc2221 lc = new lc2221();
        int[] nums1 = { 1, 2, 3, 4, 5 };
        int[] nums2 = { 5 };
        System.out.println(lc.triangularSum(nums1));
        System.out.println(lc.triangularSum(nums2));
    }
    
}
